package com.coderg.gmall.oauth2.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.coderg.gmall.model.user.UserInfo;
import com.coderg.gmall.oauth2.mapper.UserInfoMapper;
import com.coderg.gmall.oauth2.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    /**
     * 查询用户信息
     *
     * @param username
     * @return
     */
    @Override
    public UserInfo getUserInfo(String username) {
        //参数校验
        if(StringUtils.isEmpty(username)){
            return null;
        }
        return userInfoMapper.selectOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getLoginName, username));
    }
}
